package com.lxb;

public class TwoParFun {
    public static void main(String[] args) {

        int compute = TwoParFun.compute();
        System.out.println(compute);

    }

    public static int compute(){
        int num = 5;
        int arr[] = {1,2,3,4,5,6,7,8,9};

        int low = 0;
        int high = arr.length-1;

        while(low <= high){
            int mid = new Integer((low+high) / 2);
            if (num == arr[mid]){
                return mid;
            }else if (arr[mid] < num){
                low = mid + 1;
            }else {
                high = mid -1;
            }
        }
        return -1;
    }
}
